package com.server;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.Helper.*;

public class RefundCompleteServlet extends CustomerServlet
{
	private static final long serialVersionUID = 1L;
	private final String className = "Refund Complete Servlet: ";
	String msg = null;
			
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException
	{
		ConnectDB();
		if (req.getParameter("OK") != null)
		{
			Refund(req, resp);
		}
		else if (req.getParameter("Cancel") != null)
		{
			Cancel(req, resp);
		}	
	}
	
	private void Refund(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException
	{
		String firstName = req.getParameter("firstName");
		String lastName = req.getParameter("lastName");
		String seatID = req.getParameter("seatID");	
		String meal = req.getParameter("meal");
		String username = req.getParameter("username");
		String flightID = req.getParameter("flightID");
		String resID = req.getParameter("resID");
		String refundPrice = req.getParameter("refundPrice");
		String refundPoint = req.getParameter("refundPoint");
		String flight = "'"+flightID+"'";
		req.setAttribute("firstName", firstName);
		req.setAttribute("lastName", lastName);
		req.setAttribute("seatID", seatID);
		req.setAttribute("meal", meal);
		req.setAttribute("username", username);
		req.setAttribute("flightID", flightID);
		req.setAttribute("resID", resID);
		req.setAttribute("flight", flight);
		
		try 
		{		
			CustomerHelper.Setup(connection);
			CustomerHelper.AddPoint(username, Integer.parseInt(refundPoint));
			
			req.getRequestDispatcher("reservation/ModGeneral.jsp").forward(req, resp);
		} 
		catch (SQLException e) 
		{
			e.printStackTrace();
		}
	}
	
	private void Cancel(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException
	{
		
	}
}



